layui.define(['jquery', 'form'], function(exports) {
	var $ = layui.jquery,
		form = layui.form;
	var mojia = {
		init: function(elem) {
			$(elem).hide();
			var icons = '';
			var data = this.data();
			for (var i = 0; i < data.length; i++) {
				icons += '<dd class="mo-font-item"><i class="mo-icon-font ' + data[i] + '"></i></dd>';
			}
			$(elem).each(function() {
				var item = $(this);
				var font = item.val() ? item.val() : 'mo-icon-shibai-line';
				item.after('<div class="mo-font-info layui-unselect layui-form-select"><div class="mo-font-boxs"><span class="mo-font-icon layui-unselect"><i class="mo-icon-font ' + font + '"></i></span><i class="layui-edge"></i></div><dl class="mo-font-anim layui-anim layui-anim-upbit">' + icons + '</dl>');
			});
			this.select();
			this.check();
		},
		data: function() {
			var arrs = [
				'mo-icon-xiaoshi-line',
				'mo-icon-xiaoshi-fill',
				'mo-icon-yinhangka-line',
				'mo-icon-yinhangka-fill',
				'mo-icon-yanjing-line',
				'mo-icon-yanjing-fill',
				'mo-icon-yingchengka-line',
				'mo-icon-yingchengka-fill',
				'mo-icon-yanchu-line',
				'mo-icon-yanchu-fill',
				'mo-icon-yingyuan-line',
				'mo-icon-yingyuan-fill',
				'mo-icon-zengjia-line',
				'mo-icon-zengjia-fill',
				'mo-icon-youhuiquan-line',
				'mo-icon-youhuiquan-fill',
				'mo-icon-xiangji-line',
				'mo-icon-xiangji-fill',
				'mo-icon-wode-line',
				'mo-icon-wode-fill',
				'mo-icon-tanhao-line',
				'mo-icon-tanhao-fill',
				'mo-icon-pinglun-line',
				'mo-icon-pinglun-fill',
				'mo-icon-shandian-line',
				'mo-icon-shandian-fill',
				'mo-icon-aixin-line',
				'mo-icon-aixin-fill',
				'mo-icon-bangzhu-line',
				'mo-icon-bangzhu-fill',
				'mo-icon-chuangzuo-line',
				'mo-icon-chuangzuo-fill',
				'mo-icon-chenggong-line',
				'mo-icon-chenggong-fill',
				'mo-icon-dianhua-line',
				'mo-icon-dianhua-fill',
				'mo-icon-dianzan-line',
				'mo-icon-dianzan-fill',
				'mo-icon-dingwei-line',
				'mo-icon-dingwei-fill',
				'mo-icon-dianying-line',
				'mo-icon-dianying-fill',
				'mo-icon-dianyingpiao-line',
				'mo-icon-dianyingpiao-fill',
				'mo-icon-faxian-line',
				'mo-icon-faxian-fill',
				'mo-icon-huiyuan-line',
				'mo-icon-huiyuan-fill',
				'mo-icon-huati-line',
				'mo-icon-huati-fill',
				'mo-icon-jianshao-line',
				'mo-icon-jianshao-fill',
				'mo-icon-shequ-line',
				'mo-icon-shequ-fill',
				'mo-icon-shengyin-guan',
				'mo-icon-shengyin-line',
				'mo-icon-shengyin-fill',
				'mo-icon-shibai-line',
				'mo-icon-shibai-fill',
				'mo-icon-shijian-line',
				'mo-icon-shijian-fill',
				'mo-icon-shuju-line',
				'mo-icon-shuju-fill',
				'mo-icon-shouye-line',
				'mo-icon-shouye-fill',
				'mo-icon-shouji-line',
				'mo-icon-shouji-fill',
				'mo-icon-shoucang-line',
				'mo-icon-shoucang-fill',
				'mo-icon-wenda-fill',
				'mo-icon-remen-fill',
				'mo-icon-alipay-line',
				'mo-icon-alipay-fill',
				'mo-icon-edge-line',
				'mo-icon-edge-fill',
				'mo-icon-chrome-line',
				'mo-icon-chrome-fill',
				'mo-icon-firefox-line',
				'mo-icon-firefox-fill',
				'mo-icon-opera-line',
				'mo-icon-opera-fill',
				'mo-icon-qq-line',
				'mo-icon-qq-fill',
				'mo-icon-youtube-line',
				'mo-icon-youtube-fill',
				'mo-icon-weibo-line',
				'mo-icon-weibo-fill',
				'mo-icon-wechat-line',
				'mo-icon-wechat-fill',
				'mo-icon-wechat-pay-line',
				'mo-icon-wechat-pay-fill',
				'mo-icon-group',
				'mo-icon-douyin',
				'mo-icon-aliyu',
				'mo-icon-lihe',
				'mo-icon-shezhi',
				'mo-icon-zixun',
				'mo-icon-bianjigongju',
				'mo-icon-biansu',
				'mo-icon-bianyin',
				'mo-icon-gaoqing',
				'mo-icon-shipin',
				'mo-icon-shipinbiangeng',
				'mo-icon-shipindaofang',
				'mo-icon-shipinfenge',
				'mo-icon-shipinjianji',
				'mo-icon-shipinyasuo',
				'mo-icon-texiao',
				'mo-icon-texiaoshipin',
				'mo-icon-tiaojiecanshu',
				'mo-icon-wuguanggao',
				'mo-icon-play',
				'mo-icon-qq',
				'mo-icon-qiyi',
				'mo-icon-mgtv',
				'mo-icon-youku',
				'mo-icon-pptv',
				'mo-icon-letv',
				'mo-icon-sohu',
				'mo-icon-bilibili',
				'mo-icon-kankan',
				'mo-icon-down',
				'mo-icon-xunlei',
				'mo-icon-baidu',
				'mo-icon-weiyun',
				'mo-icon-paixu',
				'mo-icon-xiangkan-kai',
				'mo-icon-xiangkan-guan',
				'mo-icon-danmu-kai',
				'mo-icon-danmu-guan',
				'mo-icon-xiayiye',
				'mo-icon-shangyiye',
				'mo-icon-xiangxia',
				'mo-icon-xiangshang',
				'mo-icon-xiaolian',
				'mo-icon-putong',
				'mo-icon-kulian',
				'mo-icon-xiayige',
				'mo-icon-shangyige',
				'mo-icon-bianji',
				'mo-icon-yanjing',
				'mo-icon-caidan',
				'mo-icon-anquan',
				'mo-icon-buganxingqu',
				'mo-icon-diantong-guan',
				'mo-icon-ditu',
				'mo-icon-diantong-kai',
				'mo-icon-dingdan',
				'mo-icon-gengduo',
				'mo-icon-fanbei',
				'mo-icon-ertongpiao',
				'mo-icon-gongyi',
				'mo-icon-hongbao',
				'mo-icon-fuzhi',
				'mo-icon-fenxiang',
				'mo-icon-huatifuhao',
				'mo-icon-jiju',
				'mo-icon-kabao',
				'mo-icon-guanzhu',
				'mo-icon-maiyizengyi',
				'mo-icon-mima',
				'mo-icon-nan',
				'mo-icon-nv',
				'mo-icon-paihangbang',
				'mo-icon-lipinka',
				'mo-icon-pengyouquan',
				'mo-icon-mingxinghuodong',
				'mo-icon-qupiao',
				'mo-icon-saoyisao',
				'mo-icon-rili',
				'mo-icon-shaixuan',
				'mo-icon-shangquan',
				'mo-icon-shanchu',
				'mo-icon-xiazai',
				'mo-icon-qinghuiyuan',
				'mo-icon-riqian',
				'mo-icon-shuaxin',
				'mo-icon-sousuo',
				'mo-icon-taolunqu',
				'mo-icon-tianjiayouhuiquan',
				'mo-icon-tishi',
				'mo-icon-tupian',
				'mo-icon-tuipiao',
				'mo-icon-weixuanzhong',
				'mo-icon-weibo',
				'mo-icon-wenjuan',
				'mo-icon-weixin',
				'mo-icon-wodeguanzhu',
				'mo-icon-xiami',
				'mo-icon-xiaoxi',
				'mo-icon-shangchuan',
				'mo-icon-xiaojuchang',
				'mo-icon-wifi',
				'mo-icon-xiaoxizhongxin',
				'mo-icon-yingpingmoban',
				'mo-icon-xiaomi',
				'mo-icon-zhibo',
				'mo-icon-youkuhuiyuan',
				'mo-icon-yulebao',
				'mo-icon-zhiwen',
				'mo-icon-yuyin',
			];
			return arrs;
		},
		select: function() {
			$(document).on('click', '.mo-font-boxs', function(data) {
				var top = $(this).parent().offset().top + $(this).parent().outerHeight() + 5 - $(window).scrollTop(),
					dlHeight = $(this).parent().find('dl').outerHeight();
				if ($(this).parent().hasClass('layui-form-selected')) {
					$('.layui-form-select').removeClass('layui-form-selected');
				} else {
					$('.layui-form-select').removeClass('layui-form-selected');
					$(this).parent().addClass('layui-form-selected');
					if (top + dlHeight > $(window).height() && top >= dlHeight) {
						$(this).parent().addClass('layui-form-selectup');
					}
				}
				data.stopPropagation();
			});
		},
		check: function() {
			$(document).on('click', '.mo-font-item', function(data) {
				var clsArr = $(data.currentTarget).find('.mo-icon-font').attr('class').split(/[\s\n]/);
				$(this).parent().prev().find('.mo-icon-font').attr('class', clsArr.join(' '));
				var font = clsArr[1] == 'mo-icon-shibai-line' ? '' : clsArr[1];
				$(this).parents('.mo-font-info').prev().attr('value', font);
			});
		}
	};
	exports('iconfonts', mojia);
});
